package com.xc.hotelmgr.consumermq.utils;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

public class SendMessageMgr {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    private String exchange = "exchange";

    /**
     * 消息队列
     * @param mqType
     * @param message
     * @param appKey
     */
    public void  sendMessage(MqType mqType, Object message, String appKey){
        switch (mqType){
            case CALLBACKHOTEL://酒店变化消息队列
                rabbitTemplate.convertAndSend(exchange + "_" + "hotel","", message);
                break;
            case CALLBACKROOM://房型变化消息队列
                rabbitTemplate.convertAndSend(exchange + "_" + "room","", message);
                break;
            case CALLBACKRP://价格政策变化消息队列
                rabbitTemplate.convertAndSend(exchange + "_" + "rp","", message);
                break;
            case CALLBACKRATES://价格库存变化消息队列
                rabbitTemplate.convertAndSend(exchange + "_" + "rates","", message);
                break;
            case HTUPDOWN:// 酒店上下架消息队列
                rabbitTemplate.convertAndSend(exchange + "_" + "HtUpDown","htupdown." + appKey, message);
                break;
            case HOTELSENDALL:// 酒店全量推送消息队列
                rabbitTemplate.convertAndSend(exchange + "_" + "sendAll","sendall." + appKey, message);
                break;
            case HTLIDLIST:// 酒店初始数据消费酒店id消息队列
                rabbitTemplate.convertAndSend(exchange + "_" + "admin","hotel_id_list", message);
                break;
            case CHANGEHOTEL:// 酒店初始数据入库消息队列
                rabbitTemplate.convertAndSend(exchange + "_" + "admin","change.hotel", message);
                break;
            case CHANGERP:// 酒店初始数据入库消息队列
                rabbitTemplate.convertAndSend(exchange + "_" + "admin","change.rp", message);
                break;
            case CHANGERATES:// 酒店初始数据入库消息队列
                rabbitTemplate.convertAndSend(exchange + "_" + "admin","change.rates", message);
                break;
            case DELRP:
                rabbitTemplate.convertAndSend(exchange + "_" + "rpDel","delete_rp." + appKey, message);
                break;
            case HTLIDLISTALL://初始化存入酒店id的消息队列
                rabbitTemplate.convertAndSend(exchange + "_" + "admin","hotel_id_list_all", message);
                break;
        }
    }
}
